# -*- coding: utf-8 -*-
# @File    : get_comp_name.py
# @Date    : 2021-11-16
# @Author  : Richard
import configparser
import os
import time

class GetCompName(object):
    """
    根据IP地址获取单位名称
    """
    def __init__(self,file):
        self.file = file

    def get_comp(self,ip):
        try:
            cf = configparser.ConfigParser()
            cf.read(self.file,encoding="utf-8")
            comp_name = cf.get("comp",ip)
            if comp_name:
                return comp_name
        except Exception as Err:
            print("获取单位名称发生错误:{0}".format(Err))